<template>
  <div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDialog">关 闭</el-button>
      <el-button @click="checkDialog">选 择</el-button>
    </div>

    <TopFilter :list="topFilterList" collapse="boolean" @filterChange="changeHandle" @onCollapse="collapseHandle"></TopFilter>

    <FilterTable
      ref="table"
      columnsRef="LHMselectCX"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :isPagination="true"
      :onColumnsChange="columns => (this.columns = columns)"
      :isSelectColumn="true"
      :onSyncTableData="tableHandle"
      selectionType="single"
      :onRowSelectChange="selectChangeHandle"
    >
      <template slot="controls" slot-scope="props"></template>
    </FilterTable>
  </div>
</template>
<script>
import { getCX } from '@/api/repair/queryStatistics/hoursStatistics';
export default {
  name: 'lhmselectCX',
  data() {
    this.multipleTable4 = null;
    return {
      topFilterList: this.createTopFilters(),
      fetchApi: getCX,
      columns: this.createTableColumns(),
      fetchParams: {},
      boolean:false,
      tableData: [] // 表单数据
    };
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  methods: {
    createTopFilters() {
      return [
        {
          type: 'INPUT',
          label: '车型代码',
          fieldName: 'MODEL_CODE'
        },
        {
          type: 'INPUT',
          label: '车型名称',
          fieldName: 'MODEL_NAME'
        }
      ];
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },

        {
          title: '车型代码', // CUS_NAME
          dataIndex: 'MODEL_CODE',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '车型名称', // CUS_MOBILE
          dataIndex: 'MODEL_NAME',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },

    // 行选中状态变化时的回调
    selectChangeHandle(val) {
      this.multipleTable4 = val; //  this.multipleTable 选中的值
      console.log(val);
    },

    checkDialog() {
      this.$emit('confirmManager', this.multipleTable4);
    },
    // 搜索
    changeHandle(val) {
      this.fetchParams = Object.assign({}, val);
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    },
    closeDialog(param) {
      this.$emit('cancelManager7', false, param);
    },
    // table动态回调函数
    tableHandle(val) {
      this.tableData = val;
    }
  }
};
</script>

<style lang="less" scoped></style>
